package com.example.luohao.myservicedemo;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * 项目名称：MyServiceDemo
 * 类描述：
 * 创建人：luohao
 * 创建时间：2018/1/25 21:51
 * 修改人：luohao
 * 修改时间：2018/1/25 21:51
 * 修改备注：
 */

public class MyService extends Service {
    String TAG = "luohao";
    MyBinder myBinder = new MyBinder();

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate: ");
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind: ");
        return myBinder;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.d(TAG, "onUnbind: ");
        return super.onUnbind(intent);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "Start_command:");
        return super.onStartCommand(intent, flags, startId);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy:");
    }

    class MyBinder extends Binder {
        public MyBinder() {
        }

        public MyService getService() {
            return MyService.this;
        }

        public void startDownload() {
            Log.d(TAG, "startDownload:");
        }
    }
}
